using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Configuration;
using System.Data;
using System.Data.Common;
using System.Xml;


public abstract class JCrudHandler : IHttpHandler{	

	private string type;
	
	public abstract string Get(HttpContext context);
	public abstract string Add(HttpContext context);
	public abstract string Edit(HttpContext context);
	public abstract string Del(HttpContext context);
	public abstract string Paging(HttpContext context);
	
	public void ProcessRequest (HttpContext context)
	{			
		context.Response.ContentType = "text/plain";			
		
		try{
		
			this.type = context.Request.Form["type"];
			
			if(this.type != ""){
				
				switch(this.type){
					case "get":{
						context.Response.Write(this.Get(context));
						break;
					}
					case "add":{
						context.Response.Write(this.Add(context));
						break;
					}
					case "edit":{
						context.Response.Write(this.Edit(context));
						break;
					}
					case "del":{
						context.Response.Write(this.Del(context));
						break;
					}
					case "paging":{
						context.Response.Write(this.Paging(context));
						break;
					}
				}
			}
			
		}
		catch(Exception ex){
			context.Response.Write("<error>" + ex.Message.ToString() + " " + ex.StackTrace + "</error>");	
		}
	}
	
	public bool IsReusable
	{
		get { return true; }
	}
} 